package d6_map_impl;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class MapTest03 {
    public static void main(String[] args) {
        //目标:掌握TreeMap的底层原理 //按照键的大小默认、不重复、无索引排序
        //只是针对键,不管值
        /*Map<Movie, String> map = new TreeMap<>(new Comparator<Movie>() {
            @Override
            public int compare(Movie o1, Movie o2) {
                return Double.compare(o1.getScore(), o2.getScore());
            }
        });*/
        Map<Movie, String> map1 = new TreeMap<>(Movie::compareTo);
        Map<Movie, String> map = new TreeMap<>((m1,m2)->Double.compare(m1.getScore(),m2.getScore()));
        Map<Movie, String> map3 = new TreeMap<>(Comparator.comparingDouble(Movie::getScore));

        //添加数据
        map.put(new Movie("遮天", 9.8, "姬紫月,叶凡"),"周三上午10:00");
        map.put(new Movie("一年永恒", 9.7, "张小凡,红尘女"),"周三上午10:00");
        map.put(new Movie("沧元图", 8.9, "孟川"),"周五上午10:00");
        map.put(new Movie("凡人修仙传", 9.9, "韩立"),"周六上午11:00");
        map.put(new Movie("凡人修仙传", 9.9, "韩立"),"周六上午11:00");

        System.out.println(map);
    }
}
